package org.abacus.platform.grid.impl;

import org.abacus.platform.grid.GridData;
import org.abacus.platform.grid.ValueMap;

public class GridDataImpl implements GridData {

	/**
	 *
	 */
	private static final long serialVersionUID = 3707864721026492044L;

	ValueMap[] valueMaps;

	public ValueMap[] getValueMaps() {
		return valueMaps;
	}

	public void setValueMaps(ValueMap[] arg0) {
		valueMaps = arg0;
	}

	public void setValueMap(int arg0, ValueMap arg1) {
		valueMaps[arg0] = arg1;
	}

	public String toJson(StringBuffer arg0) {
		arg0.append('{');

		ValueMap[] vms = getValueMaps();
		if (null != vms) {
			boolean a = true;
			for (int i = 0; i < vms.length; i++) {
				if (null == vms[i]) {
					continue;
				}
				vms[i].toJson(arg0);
				if (a) {
					a = false;
				}
				arg0.append(',');
			}
			if (!a) {
				arg0.deleteCharAt(arg0.lastIndexOf(","));
			}
		}

		arg0.append('}');

		return arg0.toString();
	}

	public String toString() {
		StringBuffer sb = new StringBuffer();
		return toJson(sb);
	}
}
